<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>

</head>
<body>

<div id="app">

    <div class="demo-input-size">

        <el-table
                :data="branchArr"
                border
                style="width: 100%">
            <el-table-column
                    prop="id"
                    label="编号"
                    width="300">
            </el-table-column>
            <el-table-column
                    prop="bname"
                    label="部门名称"
                    width="400">
            </el-table-column>
            <el-table-column
                    prop="state.stname"
                    label="部门状态"
                    width="250">
            </el-table-column>

            <el-table-column
                    fixed="right"
                    label="操作"
                    width="200">
                <template slot-scope="scope">
                    <el-button type="warning" size="small" @click="updateBranch(scope.row.id)">调整</el-button>
                    <el-button type="primary" size="small" @click="branchUpdate(scope.row.id)">恢复</el-button>
                </template>
            </el-table-column>
        </el-table>


    </div>

</div>


<script>

    $.get("/ssm/branch/query",function (backData) {
        haha.branchArr=backData.data;
    });

    var haha=new Vue({
        el:"#app",
        data:{
            branchArr:[]
        },
        methods:{

            updateBranch(id){
                haha.$confirm('确认调整吗?', '温馨提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    $.get("/ssm/branch/updateBranch/"+id ,function (backData) {
                        haha.$message.success(backData.msg);
                       window.location.href="/ssm/branchcontrol/branchstate.html" ;
                    })
                });
            },

            branchUpdate(id){
                haha.$confirm('确认恢复吗?', '温馨提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    $.get("/ssm/branch/branchUpdate/"+id ,function (backData) {
                        haha.$message.success(backData.msg);
                        window.location.href="/ssm/branchcontrol/branchstate.html" ;
                    })
                });
            }

        }

    });



</script>

</body>
</html>